package com.qianfeng.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianfeng.dto.Page;
import com.qianfeng.entity.InHospital;
import com.qianfeng.mapper.InHospitalMapper;
import com.qianfeng.service.InHospitalService;
import com.qianfeng.service.MoneyHelperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

@Service
@Transactional
public class InHospitalServiceImpl implements InHospitalService {

    @Autowired
    private InHospitalMapper inHospitalMapper;


    @Override
    public void addInHospital(InHospital inHospital) {
        inHospitalMapper.addInHospital(inHospital);
    }

    @Override
    public void updateInHospital(InHospital inHospital) {
        inHospitalMapper.updateInHospital(inHospital);
    }

    @Override
    public void deleteInHospital(Integer ihId) {
        inHospitalMapper.deleteInHospital(ihId);
    }

    @Override
    public List<InHospital> getInHospitalList() {
        return inHospitalMapper.getInHospitalList();
    }

    @Override
    public InHospital getInHospitalById(int ihId) {
        return inHospitalMapper.getInHospitalById(ihId);
    }

    @Override
    public Page getInHospitalPage(Integer pageNo, Integer pageSize) {
        Page page = new Page();
        PageHelper.startPage(pageNo,pageSize);
        List<InHospital> inHospitalList = inHospitalMapper.getInHospitalList();
        PageInfo<InHospital> pageInfo = new PageInfo<>(inHospitalList);
        page.setObj(pageInfo.getList());
        page.setPageCount(pageInfo.getPages());
        page.setHasNext(pageInfo.isHasNextPage());
        return page;
    }

    @Override
    public void addInHospitalMoney(Integer ihId, Double money) {
        inHospitalMapper.addInHospitalMoney(ihId,money);
    }

    @Override
    public InHospital getInHospitalByRegistrationId(Integer rId) {
        return inHospitalMapper.getInHospitalByRegistrationId(rId);
    }


}
